//
//  SubsidiaryViewController.m
//  TenThousand
//
//  Created by 我的 on 16/6/28.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "SubsidiaryViewController.h"
#import "SubsidiaryTableViewCell.h"

@interface SubsidiaryViewController ()<UITableViewDelegate,UITableViewDataSource>

@end
#define SUBTITLE @[@"名称资产",@"资产规模（元）",@"资产占比"]
#define SUBTITLE1 @[@"时间",@"金额（元）",@"转出到",@"状态"]
#define SUBTITLE2 @[@"时间",@"金额（元）",@"状态",@"合同"]
#define SUBTITLE3 @[@"收益所属时间",@"收益金额（元）"]
@implementation SubsidiaryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self myTableView];
    [self createLeft:[UIImage imageNamed:@"ZHSZicon_03"] leftClick:^{
        [self.navigationController popViewControllerAnimated:YES];
    } right:nil rightClick:nil];
    
}

- (UITableView *)myTableView{
    _myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height-64) style:UITableViewStylePlain];
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    
    [self.view addSubview:_myTableView];
    return _myTableView;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.index == 0) {
        SubsidiaryTableViewCell *subCell = [tableView dequeueReusableCellWithIdentifier:@"SUBCELL" ];
        if (subCell == nil) {
            subCell = [[[NSBundle mainBundle]loadNibNamed:@"SubsidiaryTableViewCell" owner:nil options:nil]lastObject];
        }
        return subCell;
    }else{
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ID"];
        }
        return cell;
    }
    return nil;
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, 40)];
    header.backgroundColor = [UIColor whiteColor];
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 39, Screen_Width, 1)];
    lineView.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.00];
    [header addSubview:lineView];
    
    switch (self.index) {
        case 0:{
            
            for (int i = 0; i<3; i++) {
                UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake((Screen_Width/3+10) * i+30 , 0, Screen_Width/3, 40)];
                lable.text = SUBTITLE[i];
                lable.font = [UIFont systemFontOfSize:14.0f];
                
                [header addSubview:lable];
            }

        }
            
            break;
        case 1:{
            
            for (int i = 0; i<4; i++) {
                UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake((Screen_Width/4+10) * i+20 , 0, Screen_Width/4, 40)];
                lable.text = SUBTITLE1[i];
                lable.font = [UIFont systemFontOfSize:14.0f];
                
                [header addSubview:lable];
            }
            
        }
            
            break;
        case 2:{
            
            for (int i = 0; i<4; i++) {
                UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake((Screen_Width/4+10) * i+20 , 0, Screen_Width/4, 40)];
                lable.text = SUBTITLE2[i];
                lable.font = [UIFont systemFontOfSize:14.0f];
                
                [header addSubview:lable];
            }
            
        }
            
            break;
            
        case 3:{
            
            for (int i = 0; i<2; i++) {
                UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake((Screen_Width/2+50) * i+20 , 0, Screen_Width/2, 40)];
                lable.text = SUBTITLE3[i];
                lable.font = [UIFont systemFontOfSize:14.0f];
                
                [header addSubview:lable];
            }
            
        }
            
            break;
        default:
            break;
    }
    
   
    return header;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 40;
}
@end
